/*
#Copyright (c) 2013, Philippe Bordron <philippe.bordron@gmail.com>
#
# This file is part of SIPPER.
#
# DCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU LESSER GENERAL PUBLIC LICENSE for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# along with SIPPER.  If not, see <http://www.gnu.org/licenses/>
*/
package combi.wip.sipper.io.dot;

import java.util.Map;
import java.util.Set;

import org.jgrapht.ext.EdgeNameProvider;

public class DOTColorEdgeNameProvider<E> implements EdgeNameProvider<E>{

	private static String defaultColor = "black";
	private Map<? extends E, String> colors;
	private static String defaultPoids = "";
	private Map<? extends E, Set<Integer>> poidsMap;
	
	public DOTColorEdgeNameProvider (Map<E, String> couleurs, Map<E, Set<Integer>> poids)
	{
		colors = couleurs;
		poidsMap = poids;
	}

	@Override
	/*public String getEdgeName(E edge) {
		if (colors.containsKey(edge))
		{
			return "\"" + edge.toString() + "\",color=" + colors.get(edge);
		}
		return "\"" + edge.toString() + "\",color=" + defaultColor;
	}*/

	public String getEdgeName(E edge) {
		String poids = defaultPoids;
		if (this.poidsMap.containsKey(edge))
		{
			poids = poidsMap.get(edge).toString();
			poids.replace('[', '{');
			poids.replace(']', '}');
			
		}
		poids = "\""+ poids + "\""; 
		if (colors.containsKey(edge))
		{
			return poids +",color=" + colors.get(edge);
		}
		return poids +",color=" + defaultColor;
	}
}
